package com.sc.nft.controller;

import cn.hutool.json.JSONUtil;
import com.meta.user.client.message.MetaUserInfoMessage;
import com.sc.nft.service.UserInfoService;
import com.sc.nft.sup.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jozu
 * @since 2024/8/21 13:43
 */
@RestController
@RequestMapping("/userSync")
public class UserSyncController {
    private static final Logger log = LoggerFactory.getLogger(UserSyncController.class);
    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("/register")
    public Result<?> userSync(@RequestBody MetaUserInfoMessage userInfoMessage) {
        log.info("接收到的元数据：{}", JSONUtil.toJsonStr(userInfoMessage));
        userInfoService.syncRegister(userInfoMessage);
        return Result.success();
    }
}
